﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace PizzaWic.customer
{
    public partial class DisplayCommand : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //premier acces pour obtenir tout les raw material (pas de parametre pour le procedure stocké)
                SqlAccess sql = new SqlAccess();
                DataSet dataSetCommand = new DataSet();
                Object[] param = new Object[1];
                param[0] = Session["idCustomer"];
                

                dataSetCommand = sql.getCommandByCustomer(param);
                this.MonRepeater.ItemDataBound += new RepeaterItemEventHandler(MonRepeater_ItemDataBound);
                MonRepeater.DataSource = dataSetCommand;
                MonRepeater.DataBind();
            }
        }

        private void MonRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType !=
                    ListItemType.AlternatingItem)
                return;
            HiddenField hf = (HiddenField)e.Item.FindControl("HiddenFieldrm");
            int id = int.Parse(hf.Value);

            Repeater subrepeater = (e.Item.FindControl("Repeater2") as Repeater);
            SqlAccess sql = new SqlAccess();
            DataSet dataSetproduct = new DataSet();
            Object[] param = new Object[1];
            param[0] = id;
            dataSetproduct = sql.getProductByCommand(param);
            subrepeater.DataSource = dataSetproduct;
            subrepeater.DataBind();
        }
    }
}